/**
 * 
 */
package fr.kptn.musixmatchwrapper.util;

/**
 * Utility class to check parameters
 * 
 * @author Sylvain
 * 
 */
public class Utils {

	/**
	 * Checks if the string is empty or null
	 * 
	 * @param pString
	 *            the string to be tested
	 * @return true if the string is empty or null
	 */
	public static boolean isEmptyString(String pString) {
		boolean lEmptyString = true;

		if (pString != null && !"".equals(pString)) {
			lEmptyString = false;
		}
		return lEmptyString;
	}

	/**
	 * Checks if the string is not null and not empty
	 * 
	 * @param pString
	 *            the string to be tested
	 * @return true if the string is not null and not empty
	 */
	public static boolean isNotEmptyString(String pString) {
		return !isEmptyString(pString);
	}

	/**
	 * Checks if the specified double is within the specified range
	 * 
	 * @param pDouble
	 *            the double to be tested
	 * @param pMinorBound
	 *            the minor bound the <code>pDouble</code> parameter must be
	 *            superior to if not null
	 * @param pMajorBound
	 *            the major bound the <code>pDouble</code> parameter must be
	 *            inferior to if not null
	 * @return true if the specified double is within the specified range
	 */
	public static boolean doubleMatchRangeIfNotNull(Double pDouble, Double pMinorBound, Double pMajorBound) {
		boolean lMatchRange = true;

		if (pDouble != null) {
			if (pMinorBound != null && pDouble.compareTo(pMinorBound) < 0) {
				lMatchRange = false;
			}
			if (pMajorBound != null && pMajorBound.compareTo(pDouble) < 0) {
				lMatchRange = false;
			}
		}

		return lMatchRange;
	}
}
